package edu.xmu.pds;

import java.util.Timer;
import java.util.TimerTask;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.view.Menu;

import android.widget.TextView;


public class IngActivity extends Activity {

	Timer timer;
	TimerTask timerTask;
	int i=0;
	int hour=0;
	int minute=0;
	int second=0;
	String stringTime;
	TextView textView;
	
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ing);
        
        textView =(TextView)findViewById(R.id.textViewTime2);
        timer= new Timer();
        
        final Handler myhanHandler= new Handler()
        {
        	@Override
        	public void handleMessage(Message message)
        	{
        		if(message.what==0x123)
        		{
        			i++;
        			hour=i/3600;
        			minute=(i-hour*3600)/60;       			
        			second=(i-hour*3600-minute*60);
        			stringTime=""+hour+":"+minute+":"+second;
        			textView.setText(stringTime);
        		}
        	}
        };
     
        timerTask=new TimerTask() {
			
			@Override
			public void run() {
				// TODO Auto-generated method stub
				Message message= new Message();
				message.what=0x123;
				myhanHandler.sendMessage(message);
			}
		};
       
	timer.schedule(timerTask, 0,1000);	
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_ing, menu);
        return true;
    }

    
}
